import React, { useState } from 'react'
import Button from './Button';
import Image from './Image';

export default function StateUp() { 
  //声明为状态 
  let [src, setSrc] = useState('http://api.xiaohigh.com/image/random');

  // //声明函数切换图片
  let change = () => {
    setSrc('http://api.xiaohigh.com/image/random?t=' + Date.now());
  }
  return (
    <div>
      <Button change={change} />
      <hr />
      {/* 使用状态 */}
      <Image url={src} />
    </div>
  )
}
